/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('igraph', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ErrorResponse {
  code?: string(name='code', example='InternalServerError'),
  message?: string(name='message', example='internal server error'),
  requestId?: string(name='requestId', example='90D6B8F5-FE97-4509-9AAB-367836C51818'),
}

model CreateGraphRequest {
  body?: string(name='body'),
  namespace?: string(name='namespace'),
}

model CreateGraphResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId', example='{}'),
  result?: map[string]any(name='result'),
}

model CreateGraphResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateGraphResponseBody(name='body'),
}

async function createGraphWithOptions(instanceId: string, graphName: string, request: CreateGraphRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateGraphResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = request.body,
  };
  var params = new OpenApi.Params{
    action = 'CreateGraph',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createGraph(instanceId: string, graphName: string, request: CreateGraphRequest): CreateGraphResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createGraphWithOptions(instanceId, graphName, request, headers, runtime);
}

model CreateGraphSchemaRequest {
  body?: string(name='body'),
  namespace?: string(name='namespace'),
}

model CreateGraphSchemaResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model CreateGraphSchemaResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateGraphSchemaResponseBody(name='body'),
}

async function createGraphSchemaWithOptions(instanceId: string, graphName: string, request: CreateGraphSchemaRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateGraphSchemaResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = request.body,
  };
  var params = new OpenApi.Params{
    action = 'CreateGraphSchema',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}/schemas`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createGraphSchema(instanceId: string, graphName: string, request: CreateGraphSchemaRequest): CreateGraphSchemaResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createGraphSchemaWithOptions(instanceId, graphName, request, headers, runtime);
}

model DeleteGraphRequest {
  namespace?: string(name='namespace'),
}

model DeleteGraphResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model DeleteGraphResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteGraphResponseBody(name='body'),
}

async function deleteGraphWithOptions(instanceId: string, graphName: string, request: DeleteGraphRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteGraphResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteGraph',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteGraph(instanceId: string, graphName: string, request: DeleteGraphRequest): DeleteGraphResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteGraphWithOptions(instanceId, graphName, request, headers, runtime);
}

model GetGraphRequest {
  namespace?: string(name='namespace'),
}

model GetGraphResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model GetGraphResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetGraphResponseBody(name='body'),
}

async function getGraphWithOptions(instanceId: string, graphName: string, request: GetGraphRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetGraphResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetGraph',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getGraph(instanceId: string, graphName: string, request: GetGraphRequest): GetGraphResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getGraphWithOptions(instanceId, graphName, request, headers, runtime);
}

model GetGraphSchemaRequest {
  namespace?: string(name='namespace'),
}

model GetGraphSchemaResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model GetGraphSchemaResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetGraphSchemaResponseBody(name='body'),
}

async function getGraphSchemaWithOptions(instanceId: string, graphName: string, graphSchemaName: string, request: GetGraphSchemaRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetGraphSchemaResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetGraphSchema',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}/schemas/${OpenApiUtil.getEncodeParam(graphSchemaName)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getGraphSchema(instanceId: string, graphName: string, graphSchemaName: string, request: GetGraphSchemaRequest): GetGraphSchemaResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getGraphSchemaWithOptions(instanceId, graphName, graphSchemaName, request, headers, runtime);
}

model GetIgraphLabelBackFlowResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model GetIgraphLabelBackFlowResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetIgraphLabelBackFlowResponseBody(name='body'),
}

async function getIgraphLabelBackFlowWithOptions(graphName: string, instanceId: string, labelName: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetIgraphLabelBackFlowResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetIgraphLabelBackFlow',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}/label/${OpenApiUtil.getEncodeParam(labelName)}/backflow`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getIgraphLabelBackFlow(graphName: string, instanceId: string, labelName: string): GetIgraphLabelBackFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getIgraphLabelBackFlowWithOptions(graphName, instanceId, labelName, headers, runtime);
}

model GetIgraphLabelLastBackflowResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model GetIgraphLabelLastBackflowResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetIgraphLabelLastBackflowResponseBody(name='body'),
}

async function getIgraphLabelLastBackflowWithOptions(instanceId: string, graphName: string, labelName: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetIgraphLabelLastBackflowResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetIgraphLabelLastBackflow',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}/label/${OpenApiUtil.getEncodeParam(labelName)}/backflow/last`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getIgraphLabelLastBackflow(instanceId: string, graphName: string, labelName: string): GetIgraphLabelLastBackflowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getIgraphLabelLastBackflowWithOptions(instanceId, graphName, labelName, headers, runtime);
}

model GetIgraphTableDetailResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model GetIgraphTableDetailResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetIgraphTableDetailResponseBody(name='body'),
}

async function getIgraphTableDetailWithOptions(instanceId: string, graphName: string, tableName: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetIgraphTableDetailResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetIgraphTableDetail',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}/tables/${OpenApiUtil.getEncodeParam(tableName)}/detail`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getIgraphTableDetail(instanceId: string, graphName: string, tableName: string): GetIgraphTableDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getIgraphTableDetailWithOptions(instanceId, graphName, tableName, headers, runtime);
}

model GetIgraphTablesBackFlowRequest {
  namespace?: string(name='namespace'),
}

model GetIgraphTablesBackFlowResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model GetIgraphTablesBackFlowResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetIgraphTablesBackFlowResponseBody(name='body'),
}

async function getIgraphTablesBackFlowWithOptions(instanceId: string, graphName: string, request: GetIgraphTablesBackFlowRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetIgraphTablesBackFlowResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetIgraphTablesBackFlow',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}/backflows`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getIgraphTablesBackFlow(instanceId: string, graphName: string, request: GetIgraphTablesBackFlowRequest): GetIgraphTablesBackFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getIgraphTablesBackFlowWithOptions(instanceId, graphName, request, headers, runtime);
}

model GetInstanceRequest {
  namespace?: string(name='namespace'),
}

model GetInstanceResponseBody = {
  code?: string(name='code', example='SystemError'),
  message?: string(name='message', example='SystemError'),
  requestId?: string(name='requestId', example='90D6B8F5-FE97-4509-9AAB-367836C51818'),
  result?: {
    resourceGroupId?: string(name='resourceGroupId'),
  }(name='result'),
}

model GetInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetInstanceResponseBody(name='body'),
}

async function getInstanceWithOptions(instanceId: string, request: GetInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetInstanceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetInstance',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getInstance(instanceId: string, request: GetInstanceRequest): GetInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getInstanceWithOptions(instanceId, request, headers, runtime);
}

model GetInstanceDigestRequest {
  namespace?: string(name='namespace'),
}

model GetInstanceDigestResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model GetInstanceDigestResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetInstanceDigestResponseBody(name='body'),
}

async function getInstanceDigestWithOptions(instanceId: string, request: GetInstanceDigestRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetInstanceDigestResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetInstanceDigest',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/digest`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getInstanceDigest(instanceId: string, request: GetInstanceDigestRequest): GetInstanceDigestResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getInstanceDigestWithOptions(instanceId, request, headers, runtime);
}

model GetTableDetailResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model GetTableDetailResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetTableDetailResponseBody(name='body'),
}

async function getTableDetailWithOptions(instanceId: string, tableName: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetTableDetailResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetTableDetail',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/tables/${OpenApiUtil.getEncodeParam(tableName)}/detail`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getTableDetail(instanceId: string, tableName: string): GetTableDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getTableDetailWithOptions(instanceId, tableName, headers, runtime);
}

model GetTableLastBackflowRequest {
  partition?: string(name='partition'),
}

model GetTableLastBackflowResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model GetTableLastBackflowResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetTableLastBackflowResponseBody(name='body'),
}

async function getTableLastBackflowWithOptions(instanceId: string, tableName: string, request: GetTableLastBackflowRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetTableLastBackflowResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.partition)) {
    query['partition'] = request.partition;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetTableLastBackflow',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/table/${OpenApiUtil.getEncodeParam(tableName)}/backflow/last`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getTableLastBackflow(instanceId: string, tableName: string, request: GetTableLastBackflowRequest): GetTableLastBackflowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getTableLastBackflowWithOptions(instanceId, tableName, request, headers, runtime);
}

model ListDemoGraphSchemasResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
  returnTimeMs?: string(name='returnTimeMs'),
}

model ListDemoGraphSchemasResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListDemoGraphSchemasResponseBody(name='body'),
}

async function listDemoGraphSchemasWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ListDemoGraphSchemasResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ListDemoGraphSchemas',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/demo/schemas`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listDemoGraphSchemas(): ListDemoGraphSchemasResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listDemoGraphSchemasWithOptions(headers, runtime);
}

model ListGraphSchemasRequest {
  namespace?: string(name='namespace'),
  pageLimit?: string(name='pageLimit'),
  pageStart?: string(name='pageStart'),
  returnSpec?: string(name='returnSpec'),
  schemaStatus?: string(name='schemaStatus'),
}

model ListGraphSchemasResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model ListGraphSchemasResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListGraphSchemasResponseBody(name='body'),
}

async function listGraphSchemasWithOptions(instanceId: string, graphName: string, request: ListGraphSchemasRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListGraphSchemasResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }
  if (!Util.isUnset(request.pageLimit)) {
    query['pageLimit'] = request.pageLimit;
  }
  if (!Util.isUnset(request.pageStart)) {
    query['pageStart'] = request.pageStart;
  }
  if (!Util.isUnset(request.returnSpec)) {
    query['returnSpec'] = request.returnSpec;
  }
  if (!Util.isUnset(request.schemaStatus)) {
    query['schemaStatus'] = request.schemaStatus;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListGraphSchemas',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}/schemas`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listGraphSchemas(instanceId: string, graphName: string, request: ListGraphSchemasRequest): ListGraphSchemasResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listGraphSchemasWithOptions(instanceId, graphName, request, headers, runtime);
}

model ListIgraphInstancesRequest {
  pageContinue?: string(name='pageContinue'),
  pageLimit?: string(name='pageLimit'),
  resourceGroupId?: string(name='resourceGroupId'),
  tags?: [ 
    {
      key?: string(name='key'),
      value?: string(name='value'),
    }
  ](name='tags'),
}

model ListIgraphInstancesShrinkRequest {
  pageContinue?: string(name='pageContinue'),
  pageLimit?: string(name='pageLimit'),
  resourceGroupId?: string(name='resourceGroupId'),
  tagsShrink?: string(name='tags'),
}

model ListIgraphInstancesResponseBody = {
  code?: string(name='code', example='InternalServerError'),
  message?: string(name='message', example='internal server error'),
  requestId?: string(name='requestId', example='90D6B8F5-FE97-4509-9AAB-367836C51818'),
  result?: [ 
    {
      resourceGroupId?: string(name='resourceGroupId'),
    }
  ](name='result'),
}

model ListIgraphInstancesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListIgraphInstancesResponseBody(name='body'),
}

async function listIgraphInstancesWithOptions(tmpReq: ListIgraphInstancesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListIgraphInstancesResponse {
  Util.validateModel(tmpReq);
  var request = new ListIgraphInstancesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.tags)) {
    request.tagsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.tags, 'tags', 'json');
  }
  var query : map[string]any = {};
  if (!Util.isUnset(request.pageContinue)) {
    query['pageContinue'] = request.pageContinue;
  }
  if (!Util.isUnset(request.pageLimit)) {
    query['pageLimit'] = request.pageLimit;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['resourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.tagsShrink)) {
    query['tags'] = request.tagsShrink;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListIgraphInstances',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listIgraphInstances(request: ListIgraphInstancesRequest): ListIgraphInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listIgraphInstancesWithOptions(request, headers, runtime);
}

model ListInstanceGraphRequest {
  namespace?: string(name='namespace'),
}

model ListInstanceGraphResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model ListInstanceGraphResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListInstanceGraphResponseBody(name='body'),
}

async function listInstanceGraphWithOptions(instanceId: string, request: ListInstanceGraphRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListInstanceGraphResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListInstanceGraph',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listInstanceGraph(instanceId: string, request: ListInstanceGraphRequest): ListInstanceGraphResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listInstanceGraphWithOptions(instanceId, request, headers, runtime);
}

model PublishGraphSchemaRequest {
  namespace?: string(name='namespace'),
}

model PublishGraphSchemaResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model PublishGraphSchemaResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: PublishGraphSchemaResponseBody(name='body'),
}

async function publishGraphSchemaWithOptions(instanceId: string, graphName: string, graphSchemaName: string, request: PublishGraphSchemaRequest, headers: map[string]string, runtime: Util.RuntimeOptions): PublishGraphSchemaResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'PublishGraphSchema',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}/schemas/${OpenApiUtil.getEncodeParam(graphSchemaName)}`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function publishGraphSchema(instanceId: string, graphName: string, graphSchemaName: string, request: PublishGraphSchemaRequest): PublishGraphSchemaResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return publishGraphSchemaWithOptions(instanceId, graphName, graphSchemaName, request, headers, runtime);
}

model SearchIgraphDemoResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
  returnTimeMs?: long(name='returnTimeMs'),
}

model SearchIgraphDemoResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SearchIgraphDemoResponseBody(name='body'),
}

async function searchIgraphDemoWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): SearchIgraphDemoResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'SearchIgraphDemo',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/tool/actions/search_demo`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function searchIgraphDemo(): SearchIgraphDemoResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return searchIgraphDemoWithOptions(headers, runtime);
}

model TriggerLabelBackflowRequest {
  odpsPartition?: string(name='odpsPartition'),
  timestamp?: string(name='timestamp'),
}

model TriggerLabelBackflowResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model TriggerLabelBackflowResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: TriggerLabelBackflowResponseBody(name='body'),
}

async function triggerLabelBackflowWithOptions(instanceId: string, graphName: string, labelName: string, request: TriggerLabelBackflowRequest, headers: map[string]string, runtime: Util.RuntimeOptions): TriggerLabelBackflowResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.odpsPartition)) {
    query['odpsPartition'] = request.odpsPartition;
  }
  if (!Util.isUnset(request.timestamp)) {
    query['timestamp'] = request.timestamp;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'TriggerLabelBackflow',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}/label/${OpenApiUtil.getEncodeParam(labelName)}/backflow`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function triggerLabelBackflow(instanceId: string, graphName: string, labelName: string, request: TriggerLabelBackflowRequest): TriggerLabelBackflowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return triggerLabelBackflowWithOptions(instanceId, graphName, labelName, request, headers, runtime);
}

model UpdateGraphDescriptionRequest {
  namespace?: string(name='namespace'),
}

model UpdateGraphDescriptionResponseBody = {
  code?: string(name='code'),
  message?: string(name='message'),
  requestId?: string(name='requestId'),
  result?: map[string]any(name='result'),
}

model UpdateGraphDescriptionResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpdateGraphDescriptionResponseBody(name='body'),
}

async function updateGraphDescriptionWithOptions(instanceId: string, graphName: string, request: UpdateGraphDescriptionRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateGraphDescriptionResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.namespace)) {
    query['namespace'] = request.namespace;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpdateGraphDescription',
    version = '2021-06-21',
    protocol = 'HTTPS',
    pathname = `/openapi/igraph/instances/${OpenApiUtil.getEncodeParam(instanceId)}/graphs/${OpenApiUtil.getEncodeParam(graphName)}/description`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function updateGraphDescription(instanceId: string, graphName: string, request: UpdateGraphDescriptionRequest): UpdateGraphDescriptionResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateGraphDescriptionWithOptions(instanceId, graphName, request, headers, runtime);
}

